package lexico;
import java.io.*;
import java.io.ObjectInputStream.GetField;

import symbols.Tag;
import symbols.Token;

import lexico.*;


public class Main_teste_lexico {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		LexicalAnalyzer lexer = new LexicalAnalyzer("programas-teste/programa.ldm");
//		System.out.println(lexer.program);
		System.out.println(lexer.program.length());
		String chr;
		Token token = new Token("0",0);
		
		token = lexer.getNextToken();
		System.out.println("Token: " + token.tag);
		System.out.println("\tstring: " + lexer.wordRead);
		System.out.println("Classe:" + token.getClass());
		while (token.tag != Tag.EOF) {
			token = lexer.getNextToken();
			if (token.tag == Tag.ERROR) {
				System.out.println("Erro!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
			}
			System.out.println("Token: " + token.tag);
			System.out.println("\tstring: " + lexer.wordRead);
			System.out.println("Classe:" + token.getClass());
		}
		System.out.println("Final do Arquivo");
		
//		chr = "%";
//		System.out.print(lexer.isWhitespace(chr));
		
//		chr = lexer.getNextChar(false);
		
//		int tag = lexer.getNextToken().tag;
//		System.out.println(tag);
//		while (tag > 0) {
//			System.out.println(tag);
//		}

//		while (!chr.equals("\0")) {
//			chr = lexer.getNextChar(true);
//			//verifica a palavra reservada
////			System.out.println("\nverifica a palavra reservada1");
////				String wordRead = "int";
////			if (lexer.isPalavraReservada(wordRead)) 
////				System.out.println("palavraReservada:"+wordRead);
////			
//			
////			System.out.println("\nverifica a palavra reservada2");
////			if (lexer.isLetter(chr)) {
////				String wordRead = chr;
////				if (lexer.isPalavraReservada(wordRead)) {
////					System.out.println("palavraReservada1:"+wordRead);
////				}
////				else {
////					while (!lexer.isWhitespace(chr)) {
////						wordRead = wordRead + chr;
////						chr = lexer.getNextChar(true);
////						System.out.println(lexer.isPalavraReservada(wordRead));
////					}
////					if (lexer.isPalavraReservada(wordRead)) {
////						System.out.println("palavraReservada2:"+wordRead);
////					}
////				}
////			}
//			
////			System.out.println("verifica ");
//			
////			//verifica whitespace
////			System.out.println("\nverifica whitespace");
////			if (lexer.isWhitespace(chr)) {
////				if (chr.equals("\n")) {
////					lexer.addLineNumber();
////					System.out.println();
////				}
////				System.out.print(lexer.getLineNumber());
////			}
////			//verifica se é letra
////			System.out.println("\nverifica se é letra");
////			if (lexer.isLetter(chr)) {
////				System.out.print(chr);
////			}
////			// verifica se mudou de linha
////			System.out.println("\nverifica se mudou de linha");
////			if (chr.equals("\n"))
////			System.out.print(chr + "_");
//				
//		}
//		
	}
	

}
